<?php

/**
 * Application form base class.
 *
 * @method Application getObject() Returns the current form's model object
 *
 * @package    ecollegeplus
 * @subpackage form
 * @author     Batanayi Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseApplicationForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                 => new sfWidgetFormInputHidden(),
      'number'             => new sfWidgetFormInputText(),
      'first_name'         => new sfWidgetFormInputText(),
      'last_name'          => new sfWidgetFormInputText(),
      'middle_name'        => new sfWidgetFormInputText(),
      'email'              => new sfWidgetFormInputText(),
      'program_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Program'), 'add_empty' => false)),
      'academic_period_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AcademicPeriod'), 'add_empty' => false)),
      'status'             => new sfWidgetFormInputText(),
      'enquiry_date'       => new sfWidgetFormDateTime(),
      'last_activity'      => new sfWidgetFormDateTime(),
      'completed'          => new sfWidgetFormInputText(),
      'phone_work'         => new sfWidgetFormInputText(),
      'phone_home'         => new sfWidgetFormInputText(),
      'phone_mobile'       => new sfWidgetFormInputText(),
      'gender'             => new sfWidgetFormInputText(),
      'address_line_one'   => new sfWidgetFormTextarea(),
      'address_line_two'   => new sfWidgetFormTextarea(),
      'city'               => new sfWidgetFormTextarea(),
      'postcode'           => new sfWidgetFormInputText(),
      'state_province_id'  => new sfWidgetFormInputText(),
      'country_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'id'                 => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'number'             => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'first_name'         => new sfValidatorString(array('max_length' => 255)),
      'last_name'          => new sfValidatorString(array('max_length' => 255)),
      'middle_name'        => new sfValidatorString(array('max_length' => 200, 'required' => false)),
      'email'              => new sfValidatorString(array('max_length' => 255)),
      'program_id'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Program'))),
      'academic_period_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AcademicPeriod'))),
      'status'             => new sfValidatorInteger(array('required' => false)),
      'enquiry_date'       => new sfValidatorDateTime(array('required' => false)),
      'last_activity'      => new sfValidatorDateTime(array('required' => false)),
      'completed'          => new sfValidatorInteger(array('required' => false)),
      'phone_work'         => new sfValidatorString(array('max_length' => 200, 'required' => false)),
      'phone_home'         => new sfValidatorString(array('max_length' => 255)),
      'phone_mobile'       => new sfValidatorString(array('max_length' => 255)),
      'gender'             => new sfValidatorInteger(array('required' => false)),
      'address_line_one'   => new sfValidatorString(array('max_length' => 300)),
      'address_line_two'   => new sfValidatorString(array('max_length' => 300, 'required' => false)),
      'city'               => new sfValidatorString(array('max_length' => 300, 'required' => false)),
      'postcode'           => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'state_province_id'  => new sfValidatorInteger(array('required' => false)),
      'country_id'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('application[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Application';
  }

}
